package com.yigo.cuc.infra.repo.converter;

import com.yigo.cuc.domain.customer.aggregateroot.Customer;
import com.yigo.cuc.infra.repo.dataobject.CustomerPO;
import com.yigo.framework.snapshot.SnapshotConverter;
import org.mapstruct.InheritInverseConfiguration;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.factory.Mappers;

/**
 * @author chenzl
 */
@Mapper
public interface CustomerDmo2PoConverter extends SnapshotConverter {
    CustomerDmo2PoConverter INSTANCE = Mappers.getMapper(CustomerDmo2PoConverter.class);

    @Mapping(target = "userName", source = "source.userName.userName")
    @Mapping(target = "password", source = "source.password.password")
    @Mapping(target = "phone", source = "source.phone.phone")
    @Mapping(target = "email", source = "source.email.email")
    CustomerPO toCustomerPO(Customer source);

    @InheritInverseConfiguration(name = "toCustomerPO")
    Customer toDmo(CustomerPO source);
}
